/*
 *  Created at 2011-01-30 15:07 GMT-03:00
 *  Author: Victor Williams Stafusa da Silva
 *  JSmartUnit
 */
package org.jsmartunit.statement;

import java.lang.reflect.Method;

import org.junit.Test;
import org.junit.internal.runners.statements.FailOnTimeout;
import org.junit.runners.model.Statement;

/**
 * @author Victor Williams Stafusa da Silva
 */
public final class TimeoutRunner {

    private TimeoutRunner() {}

    public static Statement withTimeout(Statement next, Method method) {
        Test annotation = method.getAnnotation(Test.class);
        if (annotation == null) return next;
        return new FailOnTimeout(next, annotation.timeout());
    }
}
